package com.example.atv;

import android.app.Activity;
import android.app.Application;
import android.util.Log;

import androidx.appcompat.app.AppCompatActivity;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * 全局应用对象
 */
public class MyApplication extends Application {

    public static final String TAG = "MyApplication";

    private HashMap<String,AppCompatActivity> atvMap;

    @Override
    public void onCreate() {
        super.onCreate();
        atvMap = new HashMap<>();
    }


    public HashMap<String, AppCompatActivity> getAtvMap() {
        return atvMap;
    }

    public void addAtv(String key,AppCompatActivity activity){
        atvMap.put(key,activity);
        Log.i(TAG, "添加Activity:"+key);
    }

    public void removeAtv(String key){
        if(atvMap.containsKey(key)){
            atvMap.remove(key);
            Log.i(TAG, "移除Activity:"+key);
        }
    }

}
